package cn.tedu.jdbc;

import cn.tedu.Util.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class JDBCDemo4 {
    public static void main(String[] args) {
        try{
            Connection connection = DBUtil.getConnection();
            Statement statement = connection.createStatement();
            //接受执行
            Scanner scanner = new Scanner(System.in);
            System.out.println("用户名：");
            String username = scanner.nextLine();
            String sql = "delete from userinfo where username = '" + username + "'";
            //i:表示运行条数
            int i = statement.executeUpdate(sql);
            if (i > 0) {
                System.out.println("注销用户成功");
            }else{
                System.out.println("注销用户失败");
            }
            connection.close();
        }catch(SQLException e){
            throw new RuntimeException();
        }

    }
}
